const Koa = require("koa");
const router=require("koa-router")();
const app=new Koa();
//中间件  任何请求都要走这里
app.use((ctx,next)=>{
  console.log(ctx)
  next()
})
router.get('/car', (ctx, next) => {
  const car=[
    {
      id:0,
      name:"奔驰",
      price:110
    },
    {
      id:1,
      name:"奥迪",
      price:100
    }
  ]
  ctx.body=car
})
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(6000,()=>{
  console.log('http://localhost:6000')
})